﻿#pragma once
#include<memory>
#include<QString>
#include <grpcpp/grpcpp.h>
#include "DataExchange.grpc.pb.h"
#include "DataExchange.pb.h"
#include "call_data.h"
#include <any>
using grpc::ClientAsyncResponseReader;
using grpc::ClientContext;
using grpc::CompletionQueue;
using grpc::Status;
using grpc::Channel;

class RpcClient {
public:
	RpcClient(std::string adress=std::string() );
	~RpcClient();
	/*
	target 为枚举变量，指代sql中 table名
	event为接收到的请求事件，保存到异步调用过程的calldata中暂存。服务端答复后，答复结果保存到event然后将此event返回
	*/
	void listTarget(int target, std::unique_ptr< Event> event);
	void ItemDetail(int target,uint32_t rowid, std::unique_ptr< Event> event);
	void start();
	void stop();
	std::shared_ptr<CompletionQueue> complettionQueue();
private:

	std::unique_ptr<DataExchange::DataQuery::Stub> stub_;
	std::shared_ptr<CompletionQueue> cq_;
//	std::thread thread_ ;
};
